#ifndef FORM_TF_H
#define FORM_TF_H

#include "sk_print_bill.h"

#include <QWidget>
#include <QSqlQuery>
#include <QMap>
#include <QSqlQueryModel>
#include <QListWidgetItem>
#include "threadyb.h"
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkInterface>
#include <QNetworkRequest>
#include <QJsonObject>
#include <QJsonArray>

namespace Ui {
class Form_tf;
}

class Form_tf : public QWidget
{
    Q_OBJECT

public:
    explicit Form_tf(QWidget *parent = nullptr);
    ~Form_tf();
    bool ghtp();
    bool fptp();
    bool saveSI();   //保存医保相关记录， fin_ipr_siinmaininfo
    bool save_ret_reg();//挂号退费信息保存
    bool save_ret_invoice();//收费退费信息保存
    bool save_invo_info();
    bool save_invo_detail();
    bool save_fee_detail();
    bool save_cancel_item();
    bool save_ord_recipe();

    void putBaseIn( QJsonObject &in, QString code);

    bool ybT(); //医保退费

signals:

    void destroyW(QString);

private slots:

    void prepare_reg();//提取挂号信息
    void prepare_recipe();//提取发票信息

    void closeEvent(QCloseEvent *event);
    void resizeEvent(QResizeEvent *event);
    void on_pbSearch_clicked();
    void on_pbExecute_clicked();
    void on_pbExit_clicked();
    void on_leFph_returnPressed();
    //void postRequestFinished(QNetworkReply *);
    void postRequestFinished(QNetworkReply *);
    void finishedSlot(QNetworkReply*);

    void on_leFph_textChanged(const QString &arg1);

    void on_pb_reprint_clicked();

private:
    Ui::Form_tf *ui;
    QSqlQuery *qrm, *qro, *qro2;
    QString sq;
    //QString regRowid, regClinicCode, regPact;   //挂号主表rowid, clinic_code, 挂号方式。 退号时需要。
    QMap<QString, QString> mpPerson;    //患者个人资料
    //QString ybToken, ybMode;    //交易令牌，医保模式 ，“card” ：读卡， “code” ： 扫码， “id” ， 身份证
    QSqlQueryModel mdList ;  //项目明细列表
    QString msgid2208;

    volatile bool httpFinished; //http结束
    bool httpSuccess;   //http成功

    //QNetworkReply * rpl ;
    QNetworkRequest request;
    //QNetworkAccessManager *m_accessM ;
QNetworkAccessManager manager ;
    QJsonObject ret2208setlinfo;
    QJsonObject ret2208setldetail;

    QString setl_id;
    QString currentMsgid;
    bool privFinance;

    QList<QString> recipes;

    sk_print_bill * bill_print;

};

#endif // FORM_TF_H
